package structuralPatterns.composite;

public class Main {

    public static void main(String[] args){

        Component rootNode = new Composite("根节点");
        Component composite = new Composite("左节点");
        Component leaf1 = new Leaf("叶子节点1");
        Component leaf2 = new Leaf("叶子节点2");
        Component leaf3 = new Leaf("叶子节点3");
        Component leaf4 = new Leaf("叶子节点4");

        composite.add(leaf1);
        composite.add(leaf3);
        rootNode.add(composite);
        rootNode.add(leaf2);
        rootNode.add(leaf4);

        rootNode.eachChild();

    }
}
